import requests


def download_picture(url: str):
    """
    下载图片
    :param url: 图片的url
    :return:
    """
    # 使用 GET 方式请求，连接时间2s，超时时间10s
    # 返回一个 Response 对象
    response_obj = requests.request("GET", url,
                                    timeout=(2, 10))
    # 状态码
    status_code = response_obj.status_code
    print(f"status_code:{status_code}")
    # 相应内容
    content = response_obj.content

    # 保存到 lol_picture.jpg 这个文件
    with open("lol_picture.jpg", "w+b") as pic_write:
        pic_write.write(content)


pic_url = ('https://gss0.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/279759ee3d6d55fb3b58e9b06f224f4a21a4dd8e'
           '.jpg')
download_picture(pic_url)
